package homework.api01.apitest02;

public class StringBuilderDemo {
    public static void main(String[] args) {
        //append添加----默认在尾部
        String str = "我要好好学习java";
        StringBuilder builder = new StringBuilder(str);
        builder.append(",为了找到一份好工作");
        System.out.println(builder);

        //delete删除
        builder.delete(0,10);
        System.out.println(builder);//,为了找到一份好工作

        //replace---替换
        builder.replace(1,10,"为了拯救世界");
        System.out.println(builder);

        //insert--插入内容
        builder.insert(0,"活着");
        System.out.println(builder);//活着,为了拯救世界

        //reverse---反转
        builder.reverse();
        System.out.println(builder);//界世救拯了为,着活

        //String和StringBuilder互转
        String str1 = "123abc";
        StringBuilder builder1 = new StringBuilder(str1);
        String str2 = builder1.toString();
    }
}
